﻿@{
    if (RequestHelper.QueryString("use") != "include")
    {
        ViewBag.Title = "编辑文章";
        Layout = "~/Views/Shared/_Admin.cshtml";
    }
    IList<Term> categorys = ViewBag.Categorys;
    IList<Term> tags = ViewBag.Tags;
    IList<Term> popCategorys = ViewBag.PopCategorys;
    IList<User> authors = ViewBag.Authors;
    User currentUser = ViewBag.CurrentUser;
    Post currentPost = ViewBag.CurrentPost;
    IList<Relation> relations = ViewBag.Relations;
}
<link type="text/css" href="/content/styles/writer.css?ver=1.0" rel="stylesheet" />
<div class="hd-title">
    <h1 class="post">编辑文章</h1>
</div>
<div id="message" class="alert">
    <button type="button" class="close" data-dismiss="alert">×</button>
    <span></span>
</div>
<!--编辑主体-->
<div class="row-fluid">
    <div class="span9">
        <!--标题框开始-->
        <div class="title">
            <label for="post_title" class="hide-text">在此键入标题</label>
            <input id="post_title" type="text" maxlength="50" placeholder="在此键入标题" autocomplete="off" value="@currentPost.Title"/>
            <input id="post_id" type="hidden" value="@currentPost.Id" />
            <input id="post_parent" type="hidden" value="@currentPost.ParentId" />
            <input id="post_type" type="hidden" value="@currentPost.Type" />
        </div>
        <!--标题框结束-->
        <div id="editor">
            <a class="add-media btn btn-small" title="添加媒体" onclick="return $EDITORUI['edui152']._onClick();"><i class="icon-music"></i>添加媒体</a>
            @{ViewBag.FormName = "post_content";
              ViewBag.FormContent = currentPost.Content;
              ViewBag.Width = "100%";
              ViewBag.Height = "300";}
            @Html.Partial("_Editor")
        </div>
        <div class="sortable-box">
            <div class="accordion-group">
                <div class="accordion-heading">
                    <a class="accordion-toggle" data-toggle="collapse" href="#slug"><span>固定链接</span><i class="tip" title="点击以切换"></i></a>
                </div>
                <div id="slug" class="accordion-body in collapse cancal-sort">
                    <div class="accordion-inner">
                        <label for="post_slug"><strong>固定链接</strong>(Slug)：</label>
                        <input id="post_slug" type="text" value="@currentPost.Slug" />
                        <p class="muted">Tips: 默认Slug为文章标题，建议修改为英文（可能有部分主机不支持中文Slug），不允许出现-（中划线）之外的其他符号或空格！</p>
                    </div>
                </div>
            </div>
            <div class="accordion-group">
                <div class="accordion-heading">
                    <a class="accordion-toggle" data-toggle="collapse" href="#excerpt"><span>摘要</span><i class="tip" title="点击以切换"></i></a>
                </div>
                <div id="excerpt" class="accordion-body in collapse cancal-sort">
                    <div class="accordion-inner">
                        <label for="post_excerpt" class="hide-text">摘要</label>
                        <textarea id="post_excerpt" rows="5" cols="80">@currentPost.Excerpt</textarea>
                        <p class="muted">摘要是您可以手动添加的内容概要，一些主题会用到这些文字。<a href="javascript:;" target="_blank">了解关于人工摘要的更多信息。</a></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--右边栏-->
    <div class="span3 sortable-box">
        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle" data-toggle="collapse" href="#publish"><span>发布</span><i class="tip" title="点击以切换"></i></a>
            </div>
            <div id="publish" class="accordion-body in collapse cancal-sort">
                <div class="accordion-inner">
                    <input id="publish_draft" class="btn btn-small" data-loading-text="请稍后..." type="button" value="保存草稿" />
                    <span class="post-tip"></span>
                    <input id="publish_preview" class="btn btn-small" type="button" value="预览" onclick="return $EDITORUI['edui265']._onClick();" />
                </div>
                <div class="accordion-inner">
                    <label for="post_status">发布状态：</label>
                    <select id="post_status">
                        <option value="-1"@(currentPost.Status == -1 ? " selected=\"selected\"" : string.Empty)>草稿</option>
                        <option value="0"@(currentPost.Status == 0 ? " selected=\"selected\"" : string.Empty)>公开发布</option>
                        <option value="1"@(currentPost.Status == 1 ? " selected=\"selected\"" : string.Empty)>加密发布</option>
                        <option value="2"@(currentPost.Status == 2 ? " selected=\"selected\"" : string.Empty)>私密日志</option>
                    </select>
                    <input id="post_istop" type="checkbox"@(currentPost.IsTop ? " checked=\"checked\"" : string.Empty)/>
                    <label for="post_istop">置顶</label>
                </div>
                <div class="post-password accordion-inner">
                    <label for="post_password">加密密码：</label>
                    <input id="post_password" type="text" maxlength="10" disabled="disabled" value="@currentPost.Password" />
                </div>
                <div id="pubdate" class="accordion-inner">
                    <label for="post_pubdate">发布时间：</label>
                    <input id="post_pubdate" data-format="yyyy年MM月dd日 HH:mm PP" type="text" value="@currentPost.Modified.ToString("yyyy年MM月dd日 hh:mm tt")" />
                    <span class="add-on">
                        <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
                    </span>
                </div>
                <div class="accordion-inner">
                    <a id="publish_recycle" class="btn btn-mini btn-link">移至回收站</a>
                    <input id="publish_public" class="btn btn-primary" data-loading-text="请稍后..." type="submit" value="更新" />
                    <span class="post-tip" style="float: right"></span>
                </div>
            </div>
        </div>
        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle" data-toggle="collapse" href="#category"><span>分类</span><i class="tip" title="点击以切换"></i></a>
            </div>
            <div id="category" class="accordion-body in collapse cancal-sort">
                <div class="accordion-inner">
                    <ul id="category_tabs">
                        <li class="current">全部分类目录
                        </li>
                        <li>最常用
                        </li>
                    </ul>
                    <div class="tab-inner current">
                        <ul class="category-list">
                            @foreach (var item in categorys)
                            {
                                <li>
                                    <label>
                                        <input class="post-category" type="checkbox" value="@item.Id"@(relations.Where(t => t.TermId == item.Id).Count() > 0 ? " checked=\"checked\"" : string.Empty)/>
                                        @item.Name
                                    </label>
                                </li>
                            }
                        </ul>
                    </div>
                    <div class="tab-inner">
                        <ul class="category-list">
                            @foreach (var item in popCategorys)
                            {
                                <li>
                                    <label>
                                        <input class="post-category" type="checkbox" value="@item.Id"@(relations.Where(t => t.TermId == item.Id).Count() > 0 ? " checked=\"checked\"" : string.Empty)/>
                                        @item.Name
                                    </label>
                                </li>
                            }
                        </ul>
                    </div>
                    <input id="post_category" type="hidden" name="post_category" />
                </div>
            </div>
        </div>
        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle" data-toggle="collapse" href="#tag"><span>标签</span><i class="tip" title="点击以切换"></i></a>
            </div>
            <div id="tag" class="accordion-body in collapse cancal-sort">
                <div class="accordion-inner">
                    <label for="post_tag" class="hide-text">文章标题</label>
                    <input id="post_tag" type="text" name="post_tag" placeholder="标签a,标签b" value="@(string.Join(",",tags.Select(t=>t.Name)))"/>
                    <input id="post_ip" type="hidden" value="post_ip" />
                    <a id="tag_marker" class="btn btn-small" title="签个到呗！"><i class="icon-map-marker"></i></a>
                    <p class="muted">多个标签请用英文逗号（,）分开</p>
                </div>
            </div>
        </div>
        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle" data-toggle="collapse" href="#auther"><span>作者</span><i class="tip" title="点击以切换"></i></a>
            </div>
            <div id="auther" class="accordion-body in collapse cancal-sort">
                <div class="accordion-inner">
                    <label class="hide-text" for="post_author">作者</label>
                    <select id="post_author">
                        @foreach (var item in authors)
                        {
                            <option value="@item.Id"@(currentUser.Id == item.Id ? " selected=\"selected\"" : string.Empty)>@item.NickName</option>
                        }
                    </select>
                </div>
            </div>
        </div>
        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle" data-toggle="collapse" href="#comment"><span>讨论</span><i class="tip" title="点击以切换"></i></a>
            </div>
            <div id="comment" class="accordion-body in collapse cancal-sort">
                <div class="accordion-inner">
                    <label for="post_comment_status">评论</label>
                    <select id="post_comment_status">
                        <option value="0"@(currentPost.CommentStatus == 0 ? " selected=\"selected\"" : string.Empty)>接受任何人评论</option>
                        <option value="1"@(currentPost.CommentStatus == 1 ? " selected=\"selected\"" : string.Empty)>仅注册用户可评论</option>
                        <option value="2"@(currentPost.CommentStatus == 2 ? " selected=\"selected\"" : string.Empty)>拒绝任何人评论</option>
                    </select>
                </div>
                <div class="accordion-inner">
                    <label for="post_ping_status">Ping</label>
                    <select id="post_ping_status">
                        <option value="0"@(currentPost.PingStatus == 0 ? " selected=\"selected\"" : string.Empty)>Open</option>
                        <option value="1"@(currentPost.PingStatus == 1 ? " selected=\"selected\"" : string.Empty)>Just Me</option>
                        <option value="2"@(currentPost.PingStatus == 2 ? " selected=\"selected\"" : string.Empty)>Close</option>
                    </select>
                </div>
            </div>
        </div>
    </div>
</div>
<!--编辑主体结束-->
<script type="text/javascript" src="/content/scripts/bootstrap/datetimepicker.js"></script>
<script type="text/javascript" src="/content/scripts/writer.js?ver=1.0"></script>
